package com.base.helper;


import lombok.extern.log4j.Log4j;
import net.sf.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * VOS 纯打电话用的接口
 */
@Log4j
public class VOSHelperSup {
    private final static String call_url="http://223.71.50.85:8080/external/server/CallBack";


    public static JSONObject getCallObject(String transactionId, String callerE164, String calleeE164s) {
        Map<String, Object> resultMap = new HashMap<String, Object>() {
            {
                put("callerE164", callerE164);
                put("calleeE164s", calleeE164s);
                put("callerDisplayNumber",calleeE164s);
                put("accessE164", "02381927406");
                put("accessE164Password", "50385429");
                put("calloutBillingE164", "10009");
                put("calloutBillingPassword", "62252784");
                put("transactionId", transactionId);

            }
        };
        JSONObject jsonObject = JSONObject.fromObject(resultMap);
        return jsonObject;
    }

    public static void main(String[] args) {
         Boolean flag=doCall("pqtomatoTest3334","18055603791","18557542013");
//       String result= WebHelper.doBodyPost(call_url,jsonObject);
        System.out.println(flag);
    }

    public static Boolean doCall(String transactionId,String caller,String caller164s){
        JSONObject jsonObject=getCallObject(transactionId,caller,caller164s);
        String result= WebHelper.doBodyPost(call_url,jsonObject);

        JSONObject jsonObject1=JSONObject.fromObject(result);

       String code= jsonObject1.getString("retCode");
       if (code.equals("0")){
           log.warn("[vosHelper 拨打电话成功]"+caller);
           return true;
       }

       return false;
    }

}
